#!/bin/bash
[% c("var/set_default_env") -%]
[% pc('go', 'var/setup', { go_tarfile => c('input_files_by_name/go') }) %]
distdir=/var/tmp/dist/[% project %]
mkdir -p $distdir

tar -C /var/tmp/dist -xf [% c('input_files_by_name/gogb') %]

mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
cd /var/tmp/build/[% project %]-[% c('version') %]

# we don't have access to the git repository during the build
sed -i Makefile -e 's|git rev-parse --short HEAD > data/revision|echo [% c("abbrev") %] > data/revision|' 
# Unset GOOS and GOARCH as they change some file names, and we don't need
# them as we are only building on x86_64
unset GOOS
unset GOARCH
make
cp bin/sandboxed-tor-browser $distdir

cd $distdir/..
[% c('zip', {
      zip_src => [ project ],
      zip_args => dest_dir _ '/' _ c('filename'),
  }) %]
